package com.ukao.pad.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by herego on 2017/6/21.
 */

public class MainEvent<T> {
    private T data;
    private static Message mMembershipCardCmdType;



    public static enum Message {
        login,quit,print,station
    }

    public MainEvent() {

    }

    public MainEvent(Message membershipCardCmdType, T data) {
        this.mMembershipCardCmdType = membershipCardCmdType;
        this.data = data;
    }

    public MainEvent(Message msg) {
        this.mMembershipCardCmdType = msg;
    }

    public static Message getMessage() {
        return mMembershipCardCmdType;
    }

    public <T> T getData() {
        return (T) data;
    }
    public static <T> void postHasData(Message msg, T data) {
        EventBus.getDefault().postSticky(new MainEvent(msg, data));
    }
    public static <T> void postNoData(Message msg) {
        EventBus.getDefault().post(new MainEvent(msg));
    }
}
